<!-- 调研问卷 -->
<template>
	<view class="surveyQuestionnaireContainer">
		<block v-if="questionList.length > 0">
			<scroll-view :scroll-y="isScroll" :style="{ height: windowHeight + 'px' }" @scrolltolower="lower" :scroll-top="scrollTop">
				<view class="surveyQuestionnaire-item flex" v-for="item,index in questionList" :key="index">
					<view class="surveyQuestionnaireBox">
						<view class="surveyQuestionnaire-title">{{item.surveyName}}</view>
						<view class="surveyQuestionnaire-time">开始时间：{{item.surveyStartTime}}</view>
						<view class="surveyQuestionnaire-time">结束时间：{{item.surveyEndTime}}</view>
					</view>
					<!-- <view class="leftLine"></view> -->
					<view class="surveyQuestionnaireBtnBox">
						<view v-if="item.userSubmitId" class="btnBg2 surveyQuestionnaireBtn" @click="jumpPage(2,item.userSubmitId,item.surveyName)">查看</view>
						<view v-else class="btnBg1 surveyQuestionnaireBtn" @click="jumpPage(1,item.surveyId,item.surveyName)">参与</view>
					</view>
				</view>
				<!-- <view class="surveyQuestionnaire-item  flex" v-for="item,index in joinedList" :key="index">
					<view class="surveyQuestionnaireBox">
						<view class="surveyQuestionnaire-title">{{item.surveyName}}</view>
						<view class="surveyQuestionnaire-time">提交时间：{{item.submitTime}}</view>
					</view>
					<view class="surveyQuestionnaireBtnBox">
						<view class="btnBg2 surveyQuestionnaireBtn mt15" @click="jumpPage(2,item.userSubmitId,item.surveyName)">查看</view>
					</view>
				</view> -->
			</scroll-view>
		</block>
		<view v-else class="noDataTxt">暂无数据</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				questionList: [],
				page: 1,
				limit: 10,
				page2: 1,
				limit2: 10,
				isScroll: true,
				windowHeight: 0,
				scrollTop: 0,
				hasMoreData: false,//是否还有更多数据
			}
		},
		onLoad() {
			let _this = this;
			wx.getSystemInfo({
				success: function(res) {
					_this.windowHeight = res.windowHeight;
				}
			})
		},
		onShow() {
			this.searchQuestionList();
			// this.searchJoinedList();
		},
		methods: {
			jumpPage(flag,surveyId,quesTitle) {
				uni.navigateTo({
					url: '/pages/joinResearch/joinResearch?flag='+flag+'&surveyId='+surveyId+'&quesTitle='+quesTitle
				});
			},
			//查询问卷列表
			searchQuestionList() {
				let _this = this;
				this.$utils.requestFun('/curriculum/surveyInfoApi/api/querySurveyInfoListApi?route=curriculum',{
					token: getApp().globalData.token,
					channelId: getApp().globalData.channelId,
					page: _this.page,
					limit: _this.limit
				},'GET').then(res=> {
					let questionListData = _this.questionList;
					if(res.data.data.data && res.data.data.data.length > 0) {
						if(_this.page == 1) {
							questionListData = [];
						}
						let questionList = res.data.data.data;
						if(questionList.length < _this.limit) {
							_this.questionList = questionListData.concat(questionList);
							_this.hasMoreData = false;
						}else {
							_this.questionList = questionListData.concat(questionList);
							_this.hasMoreData = true;
							_this.page = _this.page++;
						}
					}else {
						if(_this.page == 1) {
							_this.questionList = [];
						}else {
							_this.questionList = questionListData;
						}
					}
				})
			},
			lower(e) {
				if (this.hasMoreData) {
					let page = this.page+1;
					this.page = page;
					let page2 = this.page2 + 1;
					this.page2 = page2;
					this.searchQuestionList();
				} else {
					uni.showToast({
						title: '没有更多数据',
						icon: 'none'
					})
				}
			},
		}
	}
</script>

<style>
	.surveyQuestionnaireContainer {
		width: 100%;
		height: 100vh;
		padding-top: 20rpx;
		background: #F6F6F6;
	}
    .box_shandow {
        -moz-box-shadow: 1px 1px 6px #c0c0c0;
        -webkit-box-shadow: 1px 1px 6px #c0c0c0;
        box-shadow: 1px 1px 6px 0px #c0c0c0;
    }
	.txtOverFlow {
		overflow: hidden;
		text-overflow:ellipsis;
		white-space: nowrap;
	}
	.flex {
		display: flex;
	}
	.noDataTxt {
		color: #999999;
		text-align: center;
		margin: 100rpx 0;
		line-height: 200rpx;
	}
	.surveyQuestionnaire-item {
		width: 88%;
		min-height: 100rpx;
		margin: 20rpx 24rpx;
		padding: 37rpx 20rpx;
		border-radius: 20rpx;
		background-color: #FFFFFF;
	}
	.height100 {
		height: 100rpx !important;;
	}
	.mt15 {
		margin-top: 15% !important;
	}
	.surveyQuestionnaireBox {
		width: 72%;
	}
	.surveyQuestionnaire-title {
		font-size: 32rpx;
		font-weight: bold;
		color: #222222;
		line-height: 50rpx;
		margin-bottom: 16rpx;
	}
	.surveyQuestionnaire-time {
		font-size: 24rpx;
		font-weight: 500;
		color: #666666;
		line-height: 44rpx
	}
	/* .leftLine {
		width: 26rpx;
		height: 90%;
		margin-top: 4%;
		background-image: linear-gradient(to right, #ffffff , #EEEEEE);
	} */
	.surveyQuestionnaireBtnBox {
		width: 25%;
		background-image: linear-gradient(90deg, #fff 0px, #eee 8px, transparent 8px);
	}
	.surveyQuestionnaireBtn {
		width: 140rpx;
		height: 60rpx;
		background-size: 100% 100%;
		background-repeat: no-repeat;
		margin-top: 30%;
		margin-left: 40rpx;
		font-size: 26rpx;
		color: #FFFFFF;
		text-align: center;
		line-height: 60rpx;
	}
	.btnBg1 {
		background-image: url("https://t.acoer.cn/guoshiBgImg/joinBtnBg.png");
	}
	.btnBg2 {
		background-image: url("https://t.acoer.cn/guoshiBgImg/selectBtnBg.png");
	}
</style>
